package com.leon.dao;

import com.leon.config.DbConnectionManager;
import org.springframework.stereotype.Repository;

import java.sql.*;

@Repository
public class UserDao {

    public Integer getUserCount() throws SQLException {
        Connection conn = DbConnectionManager.getConnection();
        int count = 0;
        try {
            Statement stat = conn.createStatement();
            ResultSet resultSet = stat.executeQuery("select count(*) as c from t_user");
            while (resultSet.next()) {
                count = resultSet.getInt("c");
            }
            resultSet.close();

        }finally {
            conn.close();
        }
        return count;
    }

}
